home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1996 February / macformat-034.iso / mac / Shareware City / Developers / appe Windows 2.03 / About appe Windows < prev    next >
Encoding:
Text File  |  1995-12-07  |  14.0 KB  |  321 lines  |  [TEXT/R*ch]

  1. appe Windows 2.03
  2. =================
  3. If you have seen the Speech Manager, then you know that a background
  4. only application can put a window onto the screen (contrary to popular
  5. belief). The new Text Services Manager in System 7.1 offers documented
  6. hooks for creating, disposing, and handling floating windows. These
  7. windows are layer independent (they are floating above all programs and
  8. windows), and can work without patching traps (well, a quick jGNEFilter,
  9. but no traps).
  10.  
  11. This program demonstrates a shell application that puts a TSM window onto
  12. the screen, and intercepts update, click, and key events. You can use
  13. "sample win.c" and "sample drag.c" to see how to write your own handlers,
  14. and easily add your desired functionality within a few hours. If you don't
  15. care to look behind the scenes, you simply write the handlers from the 
  16. templates. If you want to see how it really works, you can lift the curtains
  17. and look in the other functions for yourself.
  18.  
  19. The program can work as a foreground or background-only application. The
  20. software is distributed as a foreground app, but the process to convert a
  21. program to background app is to set the "Background Only" flag in the
  22. 'SIZE' resource (or Project Flags) and to make a system extension, you
  23. should change the file type from 'APPL' to 'appe'. I have added a
  24. drag-n-drop utility to convert between foreground and background apps, as
  25. well as a file describing the differences.
  26.  
  27. I like the close box on floater windows, because its an easy way to quit
  28. the program without relying on a quit Apple Event. I have added support
  29. for hiding windows with Cmd-Escape, and to respond to screen savers and
  30. programs that take over the screen (hide the menu bar).
  31.  
  32. Other programs that use this shell include: ObiWan, Extensions Strip, 
  33. HoverBar, Virtual, and NotifyMail. Note: that Apple software uses the
  34. layer manager in undocumented ways to get the same effect for software
  35. such as AppleGuide, Control Strip, and the Speech Manager.
  36.  
  37.  
  38. Bug Fixes/Changes
  39. =================
  40.  
  41. 2.01 -> 2.03  (2.02 was not released to the public)
  42.     * Updated the TestScreenSaver() function to count to 3 before 
  43.       hiding/showing the window, which reduces flicker and stops
  44.       the window from acting strangely during PopupMenuSelect().
  45.     * The jGNEFilter helper sets the current app's A5-world (not
  46.       ours) so that it can call FindServiceWindow(), and we don't
  47.       need to repeatedly test PtInRgn().
  48.     * Replaced the Fat WDEF with 68K and PPC parts to reduce footprint.
  49.     * Fixed a memory leak with RmveResource() in Prefs code.
  50.     * The sample drag handlers now setup and restore our A5-world. 
  51.     * Updated the process description for creating a Fat Binary.
  52.     * Dropped the Symantec C code duplication for archive size.
  53.       If you need help porting AppeWin, drop me a line.
  54.     * Updated the bundled TSM Fix from 1.02 to 1.03. See the associated
  55.       ReadMe file for relevant changes.
  56.     * Updated documentation and comments.
  57.  
  58. 2.0 -> 2.01
  59.     * Moved the jGNEFilter code from a constant string to a 'jGNE' resource
  60.       that gets loaded and called as before. This removes the conditional
  61.       template filter (which I have placed in an additional text file).
  62.       I got enough mail about the mechanism that I gave in to clean design.
  63.     * Rebuilt the notification system so that it properly cleans up in both
  64.       the casual and ExitToShell() notification.
  65.     * Tightened up the Prefs code (it was over 2 years old) and even got 
  66.       rid of the *gasp* goto's.
  67.     * Reordered the main event loop a bit (swapped a few lines), but made no
  68.       major changes.
  69.     * Tracked down an incompatibility with the 68k-CFM extension that came
  70.       with the OpenDoc DR2 release. Its actually a bug in the 68k-CFM alpha
  71.       that bombs when loading the Fat WDEF. The solution is to update/remove 
  72.       the CFM extension, or to use the 68k Infinity WDEF in both the 68k and
  73.       Fat versions of AppeWin. Kewl - Not my bug!
  74.     * Updated documentation and comments.
  75.  
  76.  
  77. Legal Stuff
  78. ===========
  79. Its yours if you like it. This shell is free for you to modify and
  80. expand upon. I would like it if you tell me if you use this, but you
  81. are under no obligation. Likewise, this library is provided as is --
  82. I fixed up all the bugs I could find/create, so I could use it myself --
  83. but that doesnt necessarily mean its fit for wiping the toilet seat. :)
  84.  
  85. The enclosed extension "TSM Fix" is intended to fix problems with the
  86. jGNEFilter missing clicks bug. This INIT is also free, to be distributed
  87. with (or without) any software you have written.
  88.  
  89. In addition, the enclosed utility "appe <-> APPL" is useful so that you
  90. only have to distribute a single binary form. Again, the program is free 
  91. to be redistributed at your whim.
  92.  
  93. The cool floating window WDEF used is the Infinity Windoid by Troy Gaul.
  94. The WDEF is free, but you should read the accompanying documentation and
  95. download the full Infinity Windoid package -- it really rox!  PS - You 
  96. may consider distributing the appropriate WDEF (68K, PPC, Fat) with each
  97. version of your program. As stated above, the sample window code now picks
  98. the appropriate binary, which is included separately for each project.
  99.  
  100.  
  101. Using the library
  102. =================
  103. In scanning the source for the program, there are several key areas
  104. that you should recognize. These gotchas are important things to 
  105. remember when modifying or adding to the source.
  106.  
  107. main.c
  108.     
  109.     Faceless background applications seem to require additional stack
  110.     space. I found that 16k of additional stack seems to work. BTW, 
  111.     you want keep the memory footprint down (people don't like memory
  112.     hogs) but not too small or you will have heap space problems. I
  113.     had to fine tune my demo apps to work well in limited memory space.
  114.     
  115.     In a background-only application, the only Toolbox initialization
  116.     call that you should make is InitGraf() to setup the QD globals.
  117.     InitWindows() plays with the layer manager in a bad way, and
  118.     should be avoided.
  119.     
  120.     Use Gestalt() to check the runtime environment, and exit gracefully
  121.     with a Notification Mgr dialog.
  122.     
  123.     The event loop sucks incoming events from both WaitNextEvent() and
  124.     from a queue of forwarded events from the Event Filter. These are
  125.     dispatched automatically, as well as resolving any pending update
  126.     events.
  127.  
  128. notify.c
  129.     
  130.     A simple installer and cleanup code for posting notifications safely,
  131.     even if we are about to quit. Also set/clear a flag to keep floaters
  132.     from obscuring important notices (since Notification Mgr. interferes
  133.     with our forwarded event mechanism). BTW, if you can come up with a 
  134.     better way to dispose the memory allocated using inline code (no 
  135.     resources, etc), I would like to hear.
  136.  
  137. filter.c
  138.  
  139.     The jGNEFilter is the best way to intercept the events directed 
  140.     at our window. We check mouse and key events for relevance, and
  141.     then forward them them to the application's event loop. In this
  142.     version, the only context you get is a valid globals world --
  143.     you CAN'T handle user or update events here. They must be done
  144.     from our (complete and full) context.
  145.     
  146.     Note: the jGNEFilter may miss occasional mouse-downs. Its a bug
  147.     in the OS, and you need to look at my "TSM Fix" for a patch that
  148.     rememdies the problem. 
  149.     
  150.     Our floaters dont get update events either, so we manually
  151.     check the update region of our window and call the update
  152.     routine. We have to check every event because update events
  153.     aren't necessarily posted when just our window needs
  154.     drawing.
  155.     
  156.     Key events can be intercepted or passed through at your discretion.
  157.     By default, only Cmd-Escape is applicable and it toggles the 
  158.     visibility of the floaters. (This would be a useful feature for all
  159.     similar apps to implement, please?)
  160.     
  161.     (v2.0) Updated the TestScreenSaver() function to be so much smarter
  162.     and work from within the jGNEFilter and our own context. (2.03) The
  163.     saver is even smarter now, and does not cause window flicker during
  164.     most game startup sequences and when calling PopUpMenuSelect().
  165.     
  166.     (v2.03) MouseDowns are now tracked properly with FindServiceWindow(),
  167.     thanks to proper A5 management code. Keep in mind that FSW() is a CPU
  168.     Hog, and should not be called for every idle event -- one user found
  169.     that doing so would *double* the time spent in the whole jGNE chain.
  170.     
  171. patches.c
  172.     
  173.     The current TSM does not create a Color Window for us, so by default
  174.     we patch NewWindow to enable the desired functionality. Although this
  175.     violates our promise of patch-free operation, it gives us color --
  176.     so lose or leave it at your whim.
  177.     
  178.     (v2.0) Add a patch to ExitToShell() that cleans up if any unexpected
  179.     errors occur (esp. while debugging). Again, its up to you if you want
  180.     this in your final product -- but I consider it essential.
  181.  
  182. floaters.c
  183.     
  184.     The floater functionality parallels NewWindow(), CloseWindow(), and 
  185.     DisposeWindow() routines. When creating a floater, you should also
  186.     specify callbacks to handle events or close requests. In addition, you
  187.     can pick a "Hot Application" in which the floater will be visible (and 
  188.     hidden at all other times) or pass zero to remain visible at all times.
  189.     This is a great way to give specialized information about a particular 
  190.     program without modifying it.
  191.     
  192.     Utility routines let you walk the internal window list and extract
  193.     additional information, either by window lookup or by index. These are
  194.     used internally for updating or hiding/showing floaters, but the sample
  195.     window routines are free to use them.
  196.     
  197.     ShowHide and Update routines let you select a particular window, or
  198.     (by passing a NIL WindowPtr) walk the list of all our floaters.
  199.     
  200.     Handling events or closing all windows are sent to dispatch routines
  201.     that can find the proper handlers and forward the little events along.
  202.     
  203. sample win.c
  204.  
  205.     When creating the window, we manage a set of prefs that keep track 
  206.     how many windows we have creating. This lets us offset each new 
  207.     window, and give it an incremental title across launches. 
  208.     
  209.     The sample window code implements the necessary callbacks that 
  210.     receive incoming window events and close imperatives. That code is
  211.     responsible then for handling clicks, hotkeys, and updates.
  212.  
  213.     Controls like scroll bars or other window-activation sensitive 
  214.     elements should always be active in floaters, since all floaters
  215.     are considered active regardless of position in window list.
  216.  
  217.     The content text for the sample windows are stored off the RefCon, but
  218.     you should do anything you like for the refcon or drawing routines.
  219.     
  220. sample drag.c
  221.     
  222.     Hey, its just a demo. You can try it out, expand on it, or just rip
  223.     it out depending on what kind of utility you are writing. It supports
  224.     sending text data and receiving both text data and text files.
  225.     
  226.     (2.03) Now pass along an A5-world to the drag handlers, so that we
  227.     don't step on anyone's toes.
  228.  
  229. Compiling Fat Apps
  230.     
  231.     Since you see 2 projects, one for 68K and one for PPC, you may not 
  232.     see how to combine the files to make Fat application.  The trick I
  233.     used was to compile both 68K and PPC versions -- which should be 
  234.     identical except where the real code is located (68K='CODE'+'DATA'
  235.     resources, PPC=Data Fork & 'cfrg' rsrc.) Duplicate the PPC binary, then
  236.     use ResEdit to copy over the 'CODE', 'DATA', and 68K 'WDEF' (if you 
  237.     use it) resources from the 68K binary to the new Fat version.
  238.     Voila, both 68K and PPC can run the right code. Note, that an
  239.     earlier ReadMe left a few steps out of this process -- DOH!
  240.  
  241.     Again, I have replaced the Fat WDEF for the 68K and PPC parts to 
  242.     reduce memory footprint. You should consider it for your program.
  243.  
  244. Things Left Undone
  245.  
  246.     Although a programming guru in my own right, I have not had time or
  247.     energy to investigate certain issues that really should be handled
  248.     and discussed in this type of sample project. If you are going to
  249.     use this software and have insights into any of the following topics,
  250.     please drop me a line so that I can make use of your knowledge:
  251.     Palette Manager interactions with the floaters, Balloon Help, etc.
  252.     
  253.     Also, I am told that SetCursor() behavior differs between Sys 7.5.x 
  254.     and earlier systems. Under older system software, the foreground 
  255.     app will not know about your window and may "fight" you by calling
  256.     SetCursor() repeatedly even over your TSM floater (THINK C is very 
  257.     bad about it). Under Sys7.5 and later, SetCursor() is patched so 
  258.     that an app cannot call SetCursor() within a TSM floater -- even
  259.     your program. The code as it sits does not attempt to deal with this,
  260.     but consider that doing it right will involve installing another
  261.     patch on SetCursor() and special case each situation.
  262.     
  263.     In the next release, I hope to add code to make "ascending" and
  264.     "descending" floaters that transition between normal windows in a
  265.     layer and TSM floaters. I think I can do it by editing code within
  266.     the "black box" functions -- almost transparently to the actual
  267.     event-handling code. More on this later.
  268.     
  269.  
  270. Credits
  271.  
  272.     It's about time I make acknowledgements to the programmers and
  273.     everyone else who have contributed their time to tracking down my
  274.     bugs and making the program robust. Just like the credits at a
  275.     movie, you can leave now if you or a relative are not listed:
  276.  
  277.     * Peter Lewis, who helped turn this from a skanky hack into an 
  278.       almost legitimate hack by sending bug reports and problems on
  279.       a daily basis. 
  280.     
  281.     * Guy Fullerton, whose HoverBar program tested the limits of my
  282.       rewrite, and who introduced my AppeWindows to more people than
  283.       I even know.
  284.     
  285.     * Ammon Skidmore, who has spent almost as much time in Macsbug
  286.       as I have trying to figure out how to work around, and still
  287.       be compatible with, System (and other) Software: Balloon Help,
  288.       Text Services Manager, and SetCursor.
  289.     
  290.     * Ed Wynne, who gets to keep me on the straight and narrow and
  291.       has to listen to every off-the-wall suggestion I make. How 
  292.       could I ever release a program or hack without his help?
  293.       
  294. ... and others who have sent in bug reports or helped out:
  295.     * Peter Bierman
  296.     * Mason Bliss
  297.     * Roberto Cattaneo
  298.     * Chris Evans
  299.     * Troy Gaul
  300.     * Mark Gerl
  301.     * Dair Grant
  302.     * Scott Gruby
  303.     * Joshua Juran
  304.     * Mike Smith
  305.     * Andrew Thaler
  306.     
  307.  
  308. Finally, I want this to be a stable mechanism for something that you
  309. shouldn't be able to do. Despite the interface guidelines, there may
  310. be a use for doing this. Please send me bug reports and suggestions
  311. for improving this tool.
  312.  
  313. Matt Slot, fprefect@umich.edu - 12/5/95
  314. <http://www.sils.umich.edu/~fprefect/>
  315.  
  316.     
  317.     
  318.  
  319.  
  320.  
  321.